package face.threaddemo;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by zhangyanfei on 2019/6/26.
 *
 * @author zhangyanfei
 * @date 2019/06/26
 */
public class ThreadTest2 {
    public static void main(String[] args) {
        Storage storage = new Storage();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 5, 5, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<>());

        ProducerWithSignal producerWithSignal1 = new ProducerWithSignal("zhangsan", storage);

        ConsumerWithSignal consumerWithSignal1 = new ConsumerWithSignal("consumer1", storage);
        ConsumerWithSignal consumerWithSignal2 = new ConsumerWithSignal("consumer2", storage);
        ConsumerWithSignal consumerWithSignal3 = new ConsumerWithSignal("consumer3", storage);

        threadPoolExecutor.submit(producerWithSignal1);
        threadPoolExecutor.submit(consumerWithSignal1);
        threadPoolExecutor.submit(consumerWithSignal2);
        threadPoolExecutor.submit(consumerWithSignal3);


    }
}
